from django.http import HttpResponseRedirect
from django.shortcuts import render, HttpResponse

# Create your views here.
from reserve.models import *
from reserve.forms import *
from dms.settings import UPLOAD_DIR
import random



# 预约成员编辑
def member_register(request):
    if request.method == 'POST':
        form = MemberForm(request.POST)
        if form.is_valid():
            member = form.save()
            request.session['member']=member
            return HttpResponseRedirect('/')
        else:
            return render(request, 'reserve/member_edit.html', locals())
    else:
        form = MemberForm()
    return render(request, 'reserve/member_register.html', locals())




# 预约人员删除
def member_delete(request, id=0):
    Member.objects.get(id=id).delete()
    return HttpResponseRedirect('/admin/member_list')
